//
//  HomeController.swift
//  jingxin
//
//  Created by Yuki on 2020/8/5.
//  Copyright © 2020 Zl. All rights reserved.
//

import UIKit
import SnapKit
import HandyJSON
import Alamofire

class HomeController: BaseController {
    
    //    var ary:[HomeModel2?] = [HomeModel2?]();
    var mainView:HomeView = HomeView();
    lazy var contentScr = UIScrollView();//滑动界面
    lazy var focusView = Home_FocusView();//关注界面
    lazy var recommendView = Home_RecommendView();//推荐界面
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.isHiddenNavBar = true;
        //创建界面
        buildUI();
    }
    
    /// 创建界面
    func buildUI(){
        
        /**  顶部界面  **/
        self.mainView = HomeView.init();
        self.view.addSubview(self.mainView);
        self.mainView.snp_makeConstraints { (make) in
            make.left.top.right.equalTo(0);
            make.height.equalTo(184*height());
        }
        
        /**  滑动视图  **/
        self.contentScr = UIScrollView.init();
        self.contentScr.showsVerticalScrollIndicator = false;
        self.contentScr.showsHorizontalScrollIndicator = false;
        self.contentScr.isPagingEnabled = true;
        self.contentScr.bounces = false;
        self.contentScr.contentSize = CGSize.init(width: ScreenW()*2, height: ScreenH() - 86*height() - TabBarHeight());
        self.view.addSubview(self.contentScr);
        self.contentScr.snp_makeConstraints { (make) in
            make.left.equalTo(0);
            make.height.equalTo(ScreenH() - 86*height() - TabBarHeight());
            make.width.equalTo(ScreenW());
            make.top.equalTo(self.view).offset(98*height());
        }
        
        /**  关注界面  **/
        self.focusView = Home_FocusView.init(frame: CGRect(x: 0, y: 0, width: ScreenW(), height: ScreenH() - 86*height() - TabBarHeight()));
        self.contentScr.addSubview(self.focusView);
        
        /**  推荐界面  **/
        self.recommendView = Home_RecommendView.init(frame: CGRect(x: ScreenW(), y: 0, width: ScreenW(), height: ScreenH() - 86*height() - TabBarHeight()));
        self.contentScr.addSubview(self.recommendView);
        
        /**  设置桥接scroll  **/
        self.mainView.beginIndex = 1;
        self.mainView.bridgeScro = self.contentScr;
    }
    
    
    //MARK:创建键盘
    private lazy var editTextField:UITextField = {
        let editTextField = UITextField.init();
        editTextField.layer.borderColor = UIColor.black.cgColor;
        editTextField.layer.borderWidth = 1;
        editTextField.placeholder = "点击拉起键盘";
        return editTextField;
    }();
    
    
}
